The width of this instance’s collision box, in pixels - ANY width, including wider than the art. 0 (the default) means auto: take the width from `mask_sprite` if one is set, else from `sprite`, else 0.
mask_w: intHow wide this instance's collision box is, in pixels. Any width - narrower than the art, wider than the art, wider than the screen.
0, the default, means auto: take the width from mask_sprite if one is set, otherwise from sprite, otherwise 0. Setting it back to 0 puts the width back on auto; it is not a zero-width mask.
mask_w = 18;
mask_h = 18;An enemy drawn as a 32x32 sprite that collides as an 18x18 square. Nothing else is needed - the box is worked out from these numbers every time collision asks, so there is no asset to draw, import or keep in step.
A mask used to be a reference to another sprite: you pointed at some other piece of art, and its size became your collision box. That sounds harmless until you notice what it means - a sprite on this console is 8, 16, 32 or 64 pixels per axis and nothing else, so those were the only four widths any mask could ever have.
An 18-pixel box was not slightly awkward to ask for. It was unsayable. So was anything wider than the art, and so was anything that had to sit off-centre. The usual workaround was to draw a picture whose only job was to be a size, ship it in the ROM, and never draw it.
A mask is a rectangle. These four numbers are that rectangle, and nothing about them touches the drawing hardware, because nothing about a mask is ever drawn.
A collision rectangle has no sub-pixel meaning, so these are whole numbers. Positions are not - x and y move as smoothly as you like underneath a box that stays the size you asked for.
This is the distinction worth keeping straight, and it is the reason "auto" is a real setting rather than just "whatever it happens to be today":
sprite (or mask_sprite) currently is. Swap a 16-wide sprite for a 32-wide one mid-game and the box follows.Both are useful. An object whose art is all one size wants auto; an object that swaps between a walk and a crouch, or between four facings drawn at different widths, usually wants one honest box that does not change under it.
That is also why an editor's "auto-size" button writes 0, not today's measurement - writing the number in would look identical right up until the sprite changed.
Free of the sprite shape sizes entirely: 18 is a real mask width, and it could not be asked for at all while a mask was a reference to another sprite. Whole pixels - a collision rectangle has no sub-pixel meaning; the box itself is built in 20.12 fixed point from this number.